feat: Lightning Warriors and a boatload of stuff#1283
feat: Lightning Warriors and a boatload of stuff#1283CptMacTavish2224 wants to merge 57 commits into
Conversation
…mit-relate changes
There was a problem hiding this comment.
24 issues found across 47 files
Confidence score: 2/5
- The riskiest issue is data integrity in
datafiles/main/squads/base_squads.json,datafiles/main/chapters/template.JSON, anddatafiles/main/chapters/34.json: invalid JSON comments, malformed key names, and duplicate keys can break parsing or silently load wrong values at startup/content load — fix these files and run a full JSON/schema validation pass before merging. datafiles/main/squads/equal_spescout.jsonappears to regress 10th company composition from a unique scout+tactical setup to effectively command+single devastator, which can materially alter roster generation and campaign balance for users — restore intended company-10 squads and verify generated company totals in-game before merge.- In
scripts/scr_UnitGroup/scr_UnitGroup.gml, sergeant selection/promotion can happen before slot viability checks, so wrong-role marines may be promoted and state can drift even when squad creation fails — reorder the flow to validate squad/slot first, then mutate role/traits, and add a targeted regression test for failed creation paths. - There are multiple runtime edge-case risks in
objects/obj_ncombat/Alarm_3.gml,scripts/scr_initialize_custom/scr_initialize_custom.gml, andscripts/scr_shoot/scr_shoot.gml(combat log drain stall, scout bank overdraft/override check mismatch, and zero-HP division path), which together increase odds of hard-to-reproduce gameplay bugs — add guards for bounds/zero-HP, align instance-variable checks, and smoke-test long combats plus custom initialization before merging.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
2 issues found across 18 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
7 issues found across 47 files
Confidence score: 2/5
scripts/scr_squads/scr_squads.gmldetects invalid squad types but still dereferences the bad key, which can hard-crash squad setup flows for players. Return early (or otherwise stop execution) as soon as a squad type is invalid before merging.scripts/scr_shoot/scr_shoot.gmlcan enter spill damage on ranks with nonpositive HP, creating divide-by-zero/negative-HP behavior and targeting ranks normal alive-rank logic would skip; it also spends Speed Force ammo before confirming there are valid targets. Skip zombie ranks before spill math and move ammo consumption after_total > 0is confirmed.- Formation/state consistency is at risk across
objects/obj_pnunit/Alarm_0.gml,scripts/scr_company_order/scr_company_order.gml, andobjects/obj_controller/Create_0.gml: the 30-rank empty-column scan can delete still-live formations, company 0 can be reorganized by 1-based defaults, and bike placements can stay stale after reset. Reusedestroy_empty_column, guard company 0 in default squad application, and includebat_bike_forin reset paths to keep combat layouts stable. scripts/scr_squads/scr_squads.gmlstores company override entries by reference, so editing a live arrangement can mutate the override template and cause hard-to-reproduce future layout drift. Store/copy overrides by value to isolate templates from runtime edits before merge.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Dismissed because Cubic found issues in a newer review.
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.
Re-trigger cubic
There was a problem hiding this comment.
20 issues found across 48 files
Confidence score: 2/5
- In
scripts/scr_squads/scr_squads.gml, the new missing-sergeant promotion path can return before fulfilment counts are refreshed, so a squad can be marked unfulfilled and immediately emptied after creation — update fulfilment counts on that path and add a regression check before merging. - In
scripts/scr_squads/scr_squads.gml, callingirandomwhenpick_optionsis empty can produceirandom(-1)and a negative index crash at runtime — add an explicit empty-array guard (fail-loud or safe early return) before the random pick. - In
scripts/scr_promote/scr_promote.gml, the while loop depends entirely oncreate_squadeventually failing and has no iteration cap, which risks an infinite loop/UI hang — add a max-iteration safeguard with a clear exit/error path before merge. - Across
objects/obj_formation_bar/Create_0.gml,scripts/scr_company_order/scr_company_order.gml, andscripts/scr_UnitGroup/scr_UnitGroup.gml, repeated role/sergeant logic and deep nesting make behavior harder to reason about and increase regression risk when this area changes again — extract shared helpers in the touched paths (or at minimum centralize duplicated branches) to de-risk follow-on fixes.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="objects/obj_formation_bar/Create_0.gml">
<violation number="1" location="objects/obj_formation_bar/Create_0.gml:194">
P1: Custom agent: **Code Quality Review**
The PR adds another identical `if (unit_id == 18)` block to an existing chain of 17 identical blocks, continuing a pattern of repeated code fragments that should be abstracted into a function or lookup table.</violation>
</file>
<file name="objects/obj_controller/Create_0.gml">
<violation number="1" location="objects/obj_controller/Create_0.gml:1590">
P2: Custom agent: **Code Quality Review**
Repeated role-check pattern with fallback string literals – the new and modified conditions follow the same duplicated structure without abstraction into a function or method.</violation>
</file>
<file name="scripts/scr_shoot/scr_shoot.gml">
<violation number="1" location="scripts/scr_shoot/scr_shoot.gml:415">
P2: Custom agent: **Code Quality Review**
Magic number 30 used as the rank array size limit in multiple newly added loops without a named constant. Define a #macro (e.g., #macro MAX_FORMATION_RANKS 30) and reference it instead.</violation>
</file>
<file name="scripts/scr_company_order/scr_company_order.gml">
<violation number="1" location="scripts/scr_company_order/scr_company_order.gml:191">
P2: Custom agent: **Code Quality Review**
Repeated squad-type traversal boilerplate in `role_hierarchy()` — two consecutive loops duplicate the same nested iteration over `obj_ini.squad_types` and their keys. Merge into a single pass or extract a helper function.</violation>
<violation number="2" location="scripts/scr_company_order/scr_company_order.gml:197">
P2: Custom agent: **Code Quality Review**
Raw string literals 'type_data' and 'role' used repeatedly as struct field keys; should be constants</violation>
<violation number="3" location="scripts/scr_company_order/scr_company_order.gml:249">
P2: Custom agent: **Code Quality Review**
Excessive nesting depth (more than 3 levels) in the non-sergeant role variant loop within `role_hierarchy()`.</violation>
</file>
<file name="scripts/scr_UnitGroup/scr_UnitGroup.gml">
<violation number="1" location="scripts/scr_UnitGroup/scr_UnitGroup.gml:228">
P2: Custom agent: **Code Quality Review**
Repeated sergeant-role-group lookup logic appears three times within `create_squad` and should be extracted into a shared helper to reduce maintenance debt and risk of inconsistency.</violation>
<violation number="2" location="scripts/scr_UnitGroup/scr_UnitGroup.gml:278">
P2: Custom agent: **Code Quality Review**
Raw string literals 'Sergeant' and 'Veteran Sergeant' used as repeated identifiers should be replaced with #macro or enum constants.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| if (unit_id == 17) { | ||
| obj_controller.bat_whirl_for[obj_controller.formating] = mah_target.col_parent; | ||
| } | ||
| if (unit_id == 18) { |
There was a problem hiding this comment.
P1: Custom agent: Code Quality Review
The PR adds another identical if (unit_id == 18) block to an existing chain of 17 identical blocks, continuing a pattern of repeated code fragments that should be abstracted into a function or lookup table.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At objects/obj_formation_bar/Create_0.gml, line 194:
<comment>The PR adds another identical `if (unit_id == 18)` block to an existing chain of 17 identical blocks, continuing a pattern of repeated code fragments that should be abstracted into a function or lookup table.</comment>
<file context>
@@ -191,6 +191,9 @@ mouse_release = function(){
if (unit_id == 17) {
obj_controller.bat_whirl_for[obj_controller.formating] = mah_target.col_parent;
}
+ if (unit_id == 18) {
+ obj_controller.bat_bike_for[obj_controller.formating] = mah_target.col_parent;
+ }
</file context>
| // so they sort immediately after the generic sergeant, keeping them at the top of their squads | ||
| var _sgt_base = _roles[eROLE.SERGEANT]; | ||
| var _vsgt_base = _roles[eROLE.VETERANSERGEANT]; | ||
| var _squad_type_names = struct_get_names(obj_ini.squad_types); |
There was a problem hiding this comment.
P2: Custom agent: Code Quality Review
Repeated squad-type traversal boilerplate in role_hierarchy() — two consecutive loops duplicate the same nested iteration over obj_ini.squad_types and their keys. Merge into a single pass or extract a helper function.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/scr_company_order/scr_company_order.gml, line 191:
<comment>Repeated squad-type traversal boilerplate in `role_hierarchy()` — two consecutive loops duplicate the same nested iteration over `obj_ini.squad_types` and their keys. Merge into a single pass or extract a helper function.</comment>
<file context>
@@ -194,5 +184,79 @@ function role_hierarchy() {
+ // so they sort immediately after the generic sergeant, keeping them at the top of their squads
+ var _sgt_base = _roles[eROLE.SERGEANT];
+ var _vsgt_base = _roles[eROLE.VETERANSERGEANT];
+ var _squad_type_names = struct_get_names(obj_ini.squad_types);
+ for (var _si = 0; _si < array_length(_squad_type_names); _si++) {
+ var _sq_data = obj_ini.squad_types[$ _squad_type_names[_si]];
</file context>
| array_contains(_role_def.alternative_roles, _base_roles[_bi])) { | ||
| var _bpos = array_get_index(hierarchy, _base_roles[_bi]); | ||
| if (_bpos >= 0) { | ||
| array_insert(hierarchy, _bpos + 1, _specific_role); |
There was a problem hiding this comment.
P2: Custom agent: Code Quality Review
Excessive nesting depth (more than 3 levels) in the non-sergeant role variant loop within role_hierarchy().
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/scr_company_order/scr_company_order.gml, line 249:
<comment>Excessive nesting depth (more than 3 levels) in the non-sergeant role variant loop within `role_hierarchy()`.</comment>
<file context>
@@ -194,5 +184,79 @@ function role_hierarchy() {
+ array_contains(_role_def.alternative_roles, _base_roles[_bi])) {
+ var _bpos = array_get_index(hierarchy, _base_roles[_bi]);
+ if (_bpos >= 0) {
+ array_insert(hierarchy, _bpos + 1, _specific_role);
+ break;
+ }
</file context>
| var _role_name = squad_unit_types[r]; | ||
| var _role_def = _fill_squad[$ _role_name]; | ||
| var _primary_role_name = struct_exists(_role_def, "role") ? _role_def.role : _role_name; | ||
| if (_primary_role_name == _sgt_type || (_role_name == "Sergeant" && _sgt_type == sgt_types[0]) || (_role_name == "Veteran Sergeant" && _sgt_type == sgt_types[1])) { |
There was a problem hiding this comment.
P2: Custom agent: Code Quality Review
Raw string literals 'Sergeant' and 'Veteran Sergeant' used as repeated identifiers should be replaced with #macro or enum constants.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/scr_UnitGroup/scr_UnitGroup.gml, line 278:
<comment>Raw string literals 'Sergeant' and 'Veteran Sergeant' used as repeated identifiers should be replaced with #macro or enum constants.</comment>
<file context>
@@ -222,20 +223,74 @@ function UnitGroup(units) constructor {
+ var _role_name = squad_unit_types[r];
+ var _role_def = _fill_squad[$ _role_name];
+ var _primary_role_name = struct_exists(_role_def, "role") ? _role_def.role : _role_name;
+ if (_primary_role_name == _sgt_type || (_role_name == "Sergeant" && _sgt_type == sgt_types[0]) || (_role_name == "Veteran Sergeant" && _sgt_type == sgt_types[1])) {
+ _sgt_group = _role_name;
+ break;
</file context>
| var _fulfilled = false; | ||
| //adding multiple role sources on gen within a single squad | ||
| var _all_roles_to_fetch = array_create(0); | ||
| for (var r = 0; r < array_length(squad_unit_types); r++) { |
There was a problem hiding this comment.
P2: Custom agent: Code Quality Review
Repeated sergeant-role-group lookup logic appears three times within create_squad and should be extracted into a shared helper to reduce maintenance debt and risk of inconsistency.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/scr_UnitGroup/scr_UnitGroup.gml, line 228:
<comment>Repeated sergeant-role-group lookup logic appears three times within `create_squad` and should be extracted into a shared helper to reduce maintenance debt and risk of inconsistency.</comment>
<file context>
@@ -222,20 +223,74 @@ function UnitGroup(units) constructor {
var _fulfilled = false;
+ //adding multiple role sources on gen within a single squad
+ var _all_roles_to_fetch = array_create(0);
+ for (var r = 0; r < array_length(squad_unit_types); r++) {
+ var _primary_role = squad_unit_types[r];
+ var _primary_role_def = _fill_squad[$ _primary_role];
</file context>
There was a problem hiding this comment.
1 issue found across 8 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="scripts/scr_promote/scr_promote.gml">
<violation number="1" location="scripts/scr_promote/scr_promote.gml:132">
P2: The 100-iteration guard silently swallows either a bug or an oversized company rather than surfacing it. `create_squad` has persistent side effects (mutates `obj_ini.squads`, rewrites roles, assigns `squad` UIDs), so if it ever returns `true` without fully consuming members, this loop could fire up to 100 times and then continue as if promotion finished successfully. Likewise, a large company that legitimately needs more than 100 squads of the same role would be silently truncated. Consider tracking actual progress (e.g., verifying that each successful call reduced the pool of eligible squadless units) and adding an explicit assertion or log when the cap is reached so the condition is not silently ignored.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
| // success without exhausting members. No company holds anywhere near 100 squads | ||
| // of one type, so this cap only trips on a genuine bug rather than normal play. | ||
| var _squad_guard = 0; | ||
| while (_result[0] && _squad_guard < 100) { |
There was a problem hiding this comment.
P2: The 100-iteration guard silently swallows either a bug or an oversized company rather than surfacing it. create_squad has persistent side effects (mutates obj_ini.squads, rewrites roles, assigns squad UIDs), so if it ever returns true without fully consuming members, this loop could fire up to 100 times and then continue as if promotion finished successfully. Likewise, a large company that legitimately needs more than 100 squads of the same role would be silently truncated. Consider tracking actual progress (e.g., verifying that each successful call reduced the pool of eligible squadless units) and adding an explicit assertion or log when the cap is reached so the condition is not silently ignored.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/scr_promote/scr_promote.gml, line 132:
<comment>The 100-iteration guard silently swallows either a bug or an oversized company rather than surfacing it. `create_squad` has persistent side effects (mutates `obj_ini.squads`, rewrites roles, assigns `squad` UIDs), so if it ever returns `true` without fully consuming members, this loop could fire up to 100 times and then continue as if promotion finished successfully. Likewise, a large company that legitimately needs more than 100 squads of the same role would be silently truncated. Consider tracking actual progress (e.g., verifying that each successful call reduced the pool of eligible squadless units) and adding an explicit assertion or log when the cap is reached so the condition is not silently ignored.</comment>
<file context>
@@ -125,8 +125,13 @@ function setup_promotion_popup() {
+ // success without exhausting members. No company holds anywhere near 100 squads
+ // of one type, so this cap only trips on a genuine bug rather than normal play.
+ var _squad_guard = 0;
+ while (_result[0] && _squad_guard < 100) {
_result = _grp.create_squad(role_squad_equivilances[$ role_name[target_role]]);
+ _squad_guard++;
</file context>
General LW_Beta Notes
more detailed info in the first Lightning Warriors Beta release
Testing
Checked everything I could, it seems this is on par with main in bugs
Summary by cubic
Adds the Lightning Warriors beta with bike-heavy squads and the “Speed Force” drive-by. Reworks the combat log and shooting flow for clearer, stabler battles, and fixes armour/encumbrance setup issues found in testing.
New Features
bike_squad/attack_bike_squadfocus, promotions, unique bike formation and icon.Refactors and Fixes
default_squads; generator supports multi-role sources, alternative-role matching, unique-role checks; random-pick equipment loadouts; company view sorted and stable.id, “monastery” spelling, Librarian role label, Contemptor description; chapter template refreshed.Written for commit 32bcbbe. Summary will update on new commits.